import java.util.Scanner;

public class zhaochenhui {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int N=sc.nextInt();
        int i,sum1=0;
        for(i=0;i<N;i++){
            sum1+=i;
        }
        System.out.println(sum1);
    }



}
